<template>
  <el-table :data="userList" stripe style="width: 100%">
    <el-table-column prop="id" label="ID" width="180" />
    <el-table-column prop="nick" label="昵称" width="180" />
    <el-table-column prop="password" label="密码" />
    <el-table-column prop="sex" label="性别" />
    <el-table-column prop="phone" label="手机" />
    <el-table-column prop="email" label="邮箱" />
    <el-table-column prop="address" label="住址" />
    <el-table-column prop="createTime" label="创建时间" />
    <el-table-column prop="updateTime" label="更新时间" />
  </el-table>
</template>

<script setup>
import { doGet } from '@/stores/httpRequest.js'
import {ref, onMounted } from 'vue'
//定义响应式变量要加上括号
let userList = ref([{}])

function getData(){
  // alert(123)
  doGet("/api/users", {}).then((response)=>{
    //处理成功情况
    console.log(response.data)
    userList.value = response.data.data
  })
      .catch((error)=>{
        //处理错误情况
        console.log(error)
      })
      .finally(()=>{
        console.log("总是会执行")
      })
}

//生命周期函数
onMounted(()=>{
  getData()
})
</script>

<style scoped>

</style>
